import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:kongqi/global.dart';
import 'package:kongqi/iconfont.dart';
import 'package:kongqi/page/pm25.dart';
import 'package:kongqi/page/sort.dart';
import 'package:kongqi/page/index.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '青红空气质量管家',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int currentPage = 0;
  var pages = [IndexPage(), SortPage(), PmPage()];
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FlutterEasyLoading(child: pages[currentPage]),
      bottomNavigationBar: BottomNavigationBar(
        elevation: 100,
        items: [
          BottomNavigationBarItem(
            icon: Icon(
              IconFont.chaxun,
              color: Global.primaryColor,
              size: 22,
            ),
            title: Text(
              '空气质量查询',
              style: TextStyle(
                color: Global.primaryColor,
                fontSize: 12,
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(
              IconFont.paihang,
              color: Global.primaryColor,
              size: 22,
            ),
            title: Text(
              '空气质量排行',
              style: TextStyle(
                color: Global.primaryColor,
                fontSize: 12,
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
          BottomNavigationBarItem(
            icon: Icon(
              IconFont.pm,
              color: Global.primaryColor,
              size: 22,
            ),
            title: Text(
              'PM2.5专栏',
              style: TextStyle(
                color: Global.primaryColor,
                fontSize: 12,
                fontWeight: FontWeight.w600,
              ),
            ),
          ),
        ],
        currentIndex: currentPage,
        onTap: (int index) {
          setState(() {
            currentPage = index;
          });
        },
      ),
    );
  }
}
